package com.util;

import com.lobby.httpclient.HttpUtils;
import com.lobby.httpclient.SignUtils;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;

public class Pay
{
  Logger logger = Logger.getLogger(Pay.class);
  DataUtil d = new DataUtil();
  
  public String Moeny(String moblie, String year, String number, String yphone, String allTotal){
    String url = "https://openapi.colourlife.com/v1/gfjg/pay/unifiedorder";
    Map<String, String> testParam = new HashMap<>();
    testParam.put("business_uuid", "e3ccf625-ee0e-44a4-b138-fa02859dea04");
    testParam.put("device_info", "CZYAPP");
    testParam.put("open_id", moblie);
    testParam.put("attach", year + number);
    testParam.put("mobile", yphone);
    testParam.put("nonce_str", DataUtil.getRandomString(40));
    testParam.put("body", "eanquan");
    testParam.put("detail", "123");
    testParam.put("out_trade_no", this.d.data());
    testParam.put("total_fee", allTotal);
    testParam.put("meal_total_fee", allTotal);
    testParam.put("spbill_create_ip", "120.26.112.214");
    testParam.put("notify_url", "https://wwl.ycws.cc/h5/p/Notify");
    testParam.put("trade_type", "JSAPI");
    testParam.put("scene_info", "1000");
    testParam.put("sign", "397b9020a9dcf696466e8df24295bd73");
    testParam.put("ts", "1513996623");
    testParam.put("appID", "ICEEANQUAN-ADC5-42B8-BB2E-BC39B211FDED");
    testParam.put("signature", SignUtils.getSignature(testParam));
    String md5 = SignUtils.getSignature(testParam);
    this.logger.info("统一下单接口,生成md5:" + md5);
    String param = SignUtils.buildParams(testParam);
    this.logger.info("请求参数:" + param);
    String responseStr = HttpUtils.sendPost(url, param);
    return responseStr;
  }
}
